from game_shared import SHARED_SERVER_PORT
from player_client import PlayerClient

import time, random

#=======================================================================================================================
# Random Intelligence.
#=======================================================================================================================

class Larry(PlayerClient):
    
    def shoot_algorithm(self):
        # ---------------- 
        # Assuming Larry has knowledge about Chuck's positions - he chooses those coords with 50% liklehood.
        # ----------------        
        known = [ (0,0), (1,0), (2,0), (0,1), (1,1), (2,1), (0,2), (1,2), (2,2), (3,2), (0,3), (1,3), (2,3), (3,3), (0,4), (1,4), (2,4), (3,4), (4,4) ]
        valid_cells = self.get_valid_cells()
        
        if random.random() < 0.5:
            return valid_cells[ random.randint(0, len(valid_cells)-1) ]
        else:
            return known[ random.randint(0, len(known)-1) ]
        
    def boat_place_algorithm(self):
        return [ [ 3, 0, 0, "h" ], [ 3, 0, 1, "h"], [ 4, 0, 2, "h" ], [ 4, 0, 3, "h" ], [ 5, 0, 4, "h" ] ] 
    
    def reinitialize(self):
        pass
        

#=======================================================================================================================
# Run the AI.
#=======================================================================================================================
me = Larry( "redsea", "larry", SHARED_SERVER_PORT )
me.enter_game_client()
me.run()